﻿using System;
using HttpApiGateway;
using RpcHelper.Validate;
using RpcModularModel.Resource;
using Wedonek.RpcStore.Gateway.Interface;
using Wedonek.RpcStore.Service.Model;

namespace Wedonek.RpcStore.Gateway.Controller
{
        /// <summary>
        /// 应用标识权限
        /// </summary>
        internal class IdentityProwerController : ApiController
        {
                private readonly IIdentityProwerService _Service;

                public IdentityProwerController (IIdentityProwerService service)
                {
                        this._Service = service;
                }
                /// <summary>
                /// 获取应用系统类型权限
                /// </summary>
                /// <param name="appId"></param>
                /// <returns></returns>
                public string[] GetSystemType ([NullValidate("rpc.identity.id.null")]Guid appId)
                {
                        return _Service.GetSystemType (appId);
                }
                /// <summary>
                /// 获取已设置的权限列表
                /// </summary>
                /// <param name="appId"></param>
                /// <param name="systemType"></param>
                /// <param name="type"></param>
                /// <returns></returns>
                public string[] GetProwers (
                        [NullValidate ("rpc.identity.id.null")] Guid appId, 
                        [NullValidate ("rpc.system.type.null")][LenValidate("rpc.system.type.len",5,50)] string systemType,
                        [EnumValidate ("rpc.identity.id.null",typeof(ResourceType))] ResourceType type)
                {
                        return this._Service.GetProwers (appId, systemType, type);
                }
                /// <summary>
                /// 同步权限列表
                /// </summary>
                /// <param name="add"></param>
                public void Sync (IdentityProwerList add)
                {
                        this._Service.Sync (add);
                }
        }
}
